<?php
class Tb_Tournaments extends Models {
    private $_name = "tournaments";
    
    /*
     * Insert
     */
    public function insert($tournaments) {
        foreach ($tournaments AS $tournament) {
            $fields = 'name, source, url_club';
            $values = '"'.mysql_escape_string($tournament['name']).'",
                       "'.mysql_escape_string($tournament['source']).'",
                       "'.mysql_escape_string($tournament['url_club']).'"';
            
            $query = 'INSERT IGNORE INTO '.$this->_name.'('.$fields.')
                      VALUES('.$values.')';
            $this->query($query);
        }
    }
    
    /*
     * Get all touraments
     */
    public function get() {
        $query = 'SELECT * FROM '.$this->_name;
        $touraments = $this->fetchArray($query);
        
        return $touraments;
    }
    
    
}